@extends('user.base')
@section('title', '题库中心')
@section('content')
<div class="layui-col-md10" style="padding: 0 0 0 15px">
            <div class="layui-row layui-col-space15">
                <!--方块开始-->
                <div class="layui-col-md3 layui-col-sm6 layui-col-xs6">
                    <div class="console-link-block">
                        <div class="console-link-block-num"><span>15</span>天</div>
                        <div class="console-link-block-text">连续学习</div>
                        <i class="console-link-block-icon layui-icon layui-icon-survey"></i>
                    </div>
                </div><!--方块结束-->
                <!--方块开始-->
                <div class="layui-col-md3 layui-col-sm6 layui-col-xs6">
                    <div class="console-link-block">
                        <div class="console-link-block-num"><span>15</span>%</div>
                        <div class="console-link-block-text">准确率</div>
                        <i class="console-link-block-icon layui-icon layui-icon-ok"></i>
                    </div>
                </div><!--方块结束-->
                <!--方块开始-->
                <div class="layui-col-md3 layui-col-sm6 layui-col-xs6">
                    <div class="console-link-block">
                        <div class="console-link-block-num"><span>15</span>题</div>
                        <div class="console-link-block-text">错题数</div>
                        <i class="console-link-block-icon layui-icon layui-icon-close"></i>
                    </div>
                </div><!--方块结束-->
                <!--方块开始-->
                <div class="layui-col-md3 layui-col-sm6 layui-col-xs6">
                    <div class="console-link-block">
                        <div class="console-link-block-num"><span>{{$errors}}</span>题</div>
                        <div class="console-link-block-text">收藏题数</div>
                        <i class="console-link-block-icon layui-icon layui-icon-star"></i>
                    </div>
                </div><!--方块结束-->
            </div>

            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            {{$subject_parent->name}} - {{$subject_child->name}}
                            <a class="layui-a-tips " id="sel-sub-but" href="javascript:;" onclick="expandContent()">切换科目</a>

                        </div>
                        <div class="layui-row layui-col-space15"  id="selectsub" style="position: relative;display: none">
                            <div class="layui-col-md12">
                                <div class="layui-row layui-col-space15">
                                    <div class="layui-col-xs12 layui-col-md12">
                                        <div class="layui-card dhbwl-count-card">
                                            <div class="layui-card-header">
                                                选择科目分类
                                                <a id="btnFoldAll"  style="margin-left: 15px;float: right" href="javascript:;"><span class="layui-badge dhbwl-bg-blue">全部折叠</span></a>
                                                <a id="btnExpandAll" style="margin-left: 15px;float: right" href="javascript:;"><span class="layui-badge dhbwl-bg-blue">全部展开</span></a>
                                            </div>
                                            <div class="layui-card-body">
                                                <table id="subject"></table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>


                        </div>
                        <div class="dhbwl-shortcut">
                            <ul class="layui-row layui-col-space25">
                                <li class="layui-col-md2 layui-col-xs3">
                                    <a lay-href="home/homepage1.html">
                                        <i class="layui-icon layui-icon-console"></i>
                                        <cite>顺序练习</cite>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs3">
                                    <a lay-href="home/homepage2.html">
                                        <i class="layui-icon layui-icon-chart"></i>
                                        <cite>随机练习</cite>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs3">
                                    <a lay-href="component/layer/list.html">
                                        <i class="layui-icon layui-icon-template-1"></i>
                                        <cite>章节练习</cite>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs3">
                                    <a layadmin-event="im">
                                        <i class="layui-icon layui-icon-chat"></i>
                                        <cite>练习记录</cite>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs3">
                                    <a lay-href="component/progress/index.html">
                                        <i class="layui-icon layui-icon-find-fill"></i>
                                        <cite>收藏练习</cite>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs3">
                                    <a lay-href="app/workorder/list.html">
                                        <i class="layui-icon layui-icon-survey"></i>
                                        <cite>错题集</cite>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <!--习题集方块结束-->
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-row layui-col-space15">
                        <div class="layui-col-xs12 layui-col-md12">
                            <div class="layui-card">
                                <div class="layui-card-header">
                                    章节练习
                                </div>
                                <div class="layui-card-body">
                                    <ul class="dhbwl-list">
                                        @foreach($sections as $val)
                                        <li>
                                            <h2>
                                                <span class="layui-badge dhbwl-bg-blue">章节</span>
                                                <a>{{$val->name}}</a>

                                            </h2>
                                            <div class="dhbwl-list-badge">
                                                <a href="{{route('user.question.show',$val->id)}}" class="layui-badge dhbwl-bg-blue layui-btn">开始学习</a>
                                            </div>
                                        </li>
                                        @endforeach
                                    </ul>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>


            </div>


        </div>
    </div>
</div>
@include('user._footer')
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/user.js"></script>
<script src="/static/js/layui/layui.all.js"></script>
    <script>
        layui.config({
            base: '/static/js/'
        }).use(['element', 'treeTable'], function () {
            var element = layui.element;
            var treeTable = layui.treeTable;
            @if (session('verified'))
            layer.msg('邮箱验证已经通过');
                @endif
            var insTb = treeTable.render({
                elem: '#subject',
                url: '{{route('api.subjects.list')}}',
                text: {
                    none: '<div style="padding: 18px 0;">无科目信息，请联系管理员添加~</div>'
                },
                tree: {
                    iconIndex: 1,
                    isPidData: true,
                    treeSpid: 0,
                    idName: 'id',  // id字段名称
                    pidName: 'parent_id',
                },
                cols: [[
                    {type: 'numbers'},
                    {field: 'name', width: 540, title: '科目名称'},
                    {
                        align: 'center', title: '操作', templet: function (d) {
                            if (d.parent_id) {
                                return '<a onclick="select(\'' + d.id + '\',\'' + d.name + '\',\'{{route('user.subject.update')}}\',\'{{csrf_token()}}\')" class="layui-btn dhbwl-bg-blue layui-btn-xs" >去练习</a>';
                            }
                        }
                    }
                ]]
            });
            $('#btnExpandAll').click(function () {
                insTb.expandAll();
            });
            $('#btnFoldAll').click(function () {
                insTb.foldAll();
            });
            //知识点 表格
        });
    </script>
@endsection
